package cn.arikeky.pet.service.impl;

import cn.arikeky.basic.query.BaseQuery;
import cn.arikeky.basic.util.PageList;
import cn.arikeky.pet.domain.Pet;
import cn.arikeky.pet.domain.PetOnlineAuditLog;
import cn.arikeky.pet.mapper.PetMapper;
import cn.arikeky.pet.service.IPetOnlineAuditLogService;
import cn.arikeky.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author arikeky
 * @since 2022-10-28
 */
@Service
public class PetOnlineAuditLogServiceImpl extends BaseServiceImpl<PetOnlineAuditLog> implements IPetOnlineAuditLogService {
//    @Autowired
//    private PetMapper petMapper;
//
//    @Override
//    public PageList<PetOnlineAuditLog> queryByPage(BaseQuery query) {
//
//        PageList<PetOnlineAuditLog> petOnlineAuditLogPageList = super.queryByPage(query);
//
//
//        List<Long> petIdList = petOnlineAuditLogPageList.getRows().stream().map(PetOnlineAuditLog::getPetId).collect(Collectors.toList());
//
//        // 第三种
//        List<Pet> petList = petMapper.findByPetIdList(petIdList);
//        Map<Long, Pet> collect = petList.stream().collect(Collectors.toMap(Pet::getId, e -> e));
//        petOnlineAuditLogPageList.getRows().forEach(log -> {
//            Pet pet = collect.get(log.getPetId());
//            log.setPet(pet);
//        });
//
//
//        // 第一种
////        Map<Long,Pet> map = new HashMap<>();
////        petIdList.forEach(id ->{
////            Pet pet = petMapper.findById(id);
////            map.put(id,pet);
////
////        });
////
////        petOnlineAuditLogPageList.getRows().forEach(log->{
////            Pet pet = map.get(log.getPetId());
////            log.setPet(pet);
////        });
//
//        // 第二种
////        petOnlineAuditLogPageList.getRows().forEach(log->{
////            Pet pet = petMapper.findById(log.getPetId());
////            log.setPet(pet);
////        });
//        return petOnlineAuditLogPageList;
//
//    }
}
